package com.ds.service;

import com.ds.orm.model.User;
import com.baomidou.mybatisplus.plugins.Page;
import com.ds.core.base.BaseService;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户管理 服务实现类
 * </p>
 *
 * @author Du
 * @since 2017-11-19
 */
@Service
public class UserService extends BaseService<User>{
	
	/**
	 * 通过账号密码登录，
	 * 若无匹配，返回null
	 * 若匹配，返回user
	 * @param account
	 * @param pswd
	 * @return
	 */
    public User normalLogin(String account ,String pswd) {
    	Map<String,Object> params = new HashMap<String, Object>();
    	params.put("account", account);
    	params.put("pswd", pswd);
		Page<?> pageInfo = query(params);
		if (pageInfo.getTotal()==1) {
			User user = (User)pageInfo.getRecords().get(0);
			return user;
		}
		return null;
    }
}
